package com.tianquan.log;/**
 * @author starsea
 * @date 2024-10-20 上午10:09
 */

/**
 * @BelongsProject: uploaddemo
 * @BelongsPackage: com.tianquan.log
 * @Author: tianquan
 * @CreateTime: 2024-10-20  10:09
 * @Description: TODO
 * @Version: 1.0
 */
public class ThreadLocalContext {

    private static final ThreadLocal<Long> userId = new ThreadLocal<>();

    private static final ThreadLocal<String> path = new ThreadLocal<>();

    private static final ThreadLocal<String> ip = new ThreadLocal<>();

    public static String getIp() {
        return ip.get();
    }

    public static void setIp(String ip) {
        ThreadLocalContext.ip.set(ip);
    }

    public static void removeIp() {
        ThreadLocalContext.ip.remove();
    }

    public static Long getUserId() {
        return userId.get();
    }

    public static void setUserId(Long userId) {
        ThreadLocalContext.userId.set(userId);
    }

    public static void removeUserId() {
        ThreadLocalContext.userId.remove();
    }

    public static String getPath() {
        return path.get();
    }

    public static void setPath(String path) {
        ThreadLocalContext.path.set(path);
    }

    public static void removePath() {
        ThreadLocalContext.path.remove();
    }

    public static void clear() {
        userId.remove();
        path.remove();
        ip.remove();
    }

}
